import staffType from "./staffTypes";

const initState = {
  requestParams: {
    phone: "",
    name: "",
    begin: 0
  },
  staffTable: {
    data: [],
    count: 0
  },
  roleTable: {
    data: []
  }
};

const staffReducers = (state = initState, action: any) => {
  switch (action.type) {
    case staffType.GET_STAFF_PERSON_TABLE:
      return {
        ...state,
        staffTable: action.payload
      };

    case staffType.GET_ROLE_LIST:
      return {
        ...state,
        roleTable: {
          data: action.payload
        }
      };

    case staffType.SET_STAFF_TABLE_PARAMS:
      return {
        ...state,
        requestParams: {
          ...state.requestParams,
          ...action.payload
        }
      };

    default:
      return state;
  }
};

export default staffReducers;
